<?php
use yii\helpers\Html;

$this->title = '全市场航空公司及代理人';
$this->params['breadcrumbs'][] = $this->title;
?>
<style>
    .pagenum{
        width: 50px;
        text-align: center;
    }
    .mysearch{
        width: 60px;
        text-align: center;
    }
</style>
<div class="row">
    <div class="col-md-6">
        <div class="pagerank-list">
            <p>
                <h5>航空公司总表</h5>
            </p>
            <ul id="amylist">
            </ul>
        </div>
        <div class="page">
            <?= Html::button('上一页', ['id' => 'amypreage']) ?>
            <?= Html::input('text', 'page',1, ['id' =>'acurpage','readonly'=>true,'class'=>'pagenum']) ?>
            <?= Html::button('下一页', ['id' => 'amynextage']) ?>
            <?= Html::input('text', 'searchinput','', ['id' =>'asearchinput','class'=>'mysearch']) ?>
            <?= Html::button('搜索', ['id' => 'amysearch']) ?>
        </div>
    </div>

    <div class="col-md-6">
        <div class="pagerank-list">
            <p>
            <h5>代理人总表</h5>
            </p>
            <ul id="lmylist">
            </ul>
        </div>
        <div class="page">
            <?= Html::button('上一页', ['id' => 'lmypreage']) ?>
            <?= Html::input('text', 'page',1, ['id' =>'lcurpage','readonly'=>true,'class'=>'pagenum']) ?>
            <?= Html::button('下一页', ['id' => 'lmynextage']) ?>
            <?= Html::input('text', 'searchinput','', ['id' =>'lsearchinput','class'=>'mysearch']) ?>
            <?= Html::button('搜索', ['id' => 'lmysearch']) ?>
        </div>
    </div>
</div>
<?php $this->beginBlock('myjs') ?>
function getAirlines(page) {
$.ajax({
type: "POST",
url: '<?=\Yii::getAlias('@web')?>/site/ajaxairlines',
dataType: "json",
data:
{
page:page,
},
success: function(data)
{
$("#acurpage").val(parseInt(data.page)+1);
$("#amylist").empty();
for(var i=0;i<data.airlines.length;i++)
{
$("#amylist").append("<li>"+"&emsp;"+data.airlines[i]['sale_nbr']+"</li>");
}
},
error: function(jqXHR)
{
alert("发生错误：" + jqXHR.status);
},
});
}
getAirlines(0);
$("#amypreage").click(function(){
var curpage=$("#acurpage").val();
getAirlines(parseInt(curpage)-1-1);
});
$("#amynextage").click(function(){
var curpage=$("#acurpage").val();
getAirlines(parseInt(curpage)-1+1);
});
$("#amysearch").click(function(){
var curpage=$("#asearchinput").val();
getAirlines(parseInt(curpage)-1);
});
function getAgents(page) {
$.ajax({
type: "POST",
url: '<?=\Yii::getAlias('@web')?>/site/ajaxallagents',
dataType: "json",
data:
{
page:page,
},
success: function(data)
{
$("#lcurpage").val(parseInt(data.page)+1);
$("#lmylist").empty();
for(var i=0;i<data.agents.length;i++)
{
$("#lmylist").append("<li>"+"&emsp;"+data.agents[i]['sale_nbr']+"</li>");
}
},
error: function(jqXHR)
{
alert("发生错误：" + jqXHR.status);
},
});
}
getAgents(0);
$("#lmypreage").click(function(){
var curpage=$("#lcurpage").val();
getAgents(parseInt(curpage)-1-1);
});
$("#lmynextage").click(function(){
var curpage=$("#lcurpage").val();
getAgents(parseInt(curpage)-1+1);
});
$("#lmysearch").click(function(){
var curpage=$("#lsearchinput").val();
getAgents(parseInt(curpage)-1);
});

<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['myjs'], \yii\web\View::POS_READY); ?>